/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function monthTable(){
    var datatbl = new google.visualization.DataTable();

    //get the data from the file and load it into the google datatable
    $.getJSON('/MonthlyTableData.php', function(data) {

        //create the rows and columns in the datatable
        var noElements = data.length;
        datatbl.addColumn('string', 'Date');
        datatbl.addColumn('number', 'Temp');
        //datatbl.addColumn('number', 'Feels like');
        datatbl.addColumn('number', 'Humidity(%)');
        datatbl.addColumn('number', 'Wind Direction');
        datatbl.addColumn('number', 'Wind Avg Speed (mph)');
        //datatbl.addColumn('number', 'Wind Gust (mph)');
        datatbl.addColumn('number', 'Average Rainfall (mm)');
        datatbl.addColumn('number', 'Total Rainfall (mm)');
        datatbl.addColumn('number', 'Abs Pressure (hPa)');
        datatbl.addRows(noElements);

        //Put the data into the datatable
        $.each(data, function(i, v) {
            // set the values for both the name and the population
            datatbl.setValue(i, 0, v.Date);
            datatbl.setValue(i, 1, v.Temp);
            //datatbl.setValue(i, 2, v.FeelsLike);
            datatbl.setValue(i, 2, v.Humidity);
            datatbl.setValue(i, 3, v.WindDirection);
            datatbl.setValue(i, 4, v.WindSpeed);
           // datatbl.setValue(i, 6, v.WindGust);
            datatbl.setValue(i, 5, v.AverageRain);
            datatbl.setValue(i, 6, v.TotalRain);
            datatbl.setValue(i, 7, v.Pressure);
        });

        //declare the chart (which is a table) and draw it 
        var viewTable = new google.visualization.DataView(datatbl);
        viewTable.setColumns([0, 1, 2, 3, 4, 5, 6, 7]);
        var table = new google.visualization.Table(document.getElementById('Monthly_table_div'));
        table.draw(viewTable);
    });

}